package com.soul.eurekaclient.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/say")
public class HelloController {


    @GetMapping("/hello")
    @HystrixCommand(fallbackMethod = "hello2")
    public Map<String, Object> hello() {
        Map<String, Object> map = new HashMap<>();
        map.put("status", 200);
        map.put("data", "hello");
        map.put("msg", "success");
        return map;
    }

    public Map<String, Object> hello2() {
        Map<String, Object> map = new HashMap<>();
        map.put("status", 500);
        map.put("data", null);
        map.put("msg", "default msg");
        return map;
    }
}
